home *** CD-ROM | disk | FTP | other *** search
- /* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the License.
- *
- * The Original Code is the Autocomplete Manager extension.
- *
- * The Initial Developer of the Original Code is
- * Nikitas Liogkas <nikitas@acm.org>.
- * Portions created by the Initial Developer are Copyright (C) 2005-2008
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Version: 2.3
- *
- * ***** END LICENSE BLOCK ***** */
-
- // rdfUtils.js
- // interfaces with the RDF datasources and retrieves the boookmarks and history items
-
- // RDF service and datasources
- const acm_rdfService = Components.classes["@mozilla.org/rdf/rdf-service;1"]
- .getService(Components.interfaces.nsIRDFService);
-
- const acm_dsHistory = acm_rdfService.GetDataSource("rdf:history");
- const acm_dsBookmarks = acm_rdfService.GetDataSource("rdf:bookmarks");
-
- const acm_browserHistory = Components.classes["@mozilla.org/browser/global-history;2"]
- .getService(Components.interfaces.nsIBrowserHistory);
-
- const acm_ioService = Components.classes["@mozilla.org/network/io-service;1"]
- .getService(Components.interfaces.nsIIOService);
-
- // entry properties
- const acm_resName = acm_rdfService.GetResource("http://home.netscape.com/NC-rdf#Name");
- const acm_resURL = acm_rdfService.GetResource("http://home.netscape.com/NC-rdf#URL");
- const acm_resHistFirstVisit = acm_rdfService.GetResource("http://home.netscape.com/NC-rdf#FirstVisitDate");
- const acm_resHistLastVisit = acm_rdfService.GetResource("http://home.netscape.com/NC-rdf#Date");
- const acm_resBookFirstVisit = acm_rdfService.GetResource("http://home.netscape.com/NC-rdf#BookmarkAddDate");
- const acm_resBookLastVisit = acm_rdfService.GetResource("http://home.netscape.com/WEB-rdf#LastVisitDate");
- const acm_resBookIcon = acm_rdfService.GetResource("http://home.netscape.com/NC-rdf#Icon");
- const acm_resVisitCount = acm_rdfService.GetResource("http://home.netscape.com/NC-rdf#VisitCount");
- const acm_resChild = acm_rdfService.GetResource("http://home.netscape.com/NC-rdf#child");
- const acm_resBookmarkType = acm_rdfService.GetResource("http://www.w3.org/1999/02/22-rdf-syntax-ns#type");
-
- // Autocomplete candidate sources;
- // code in acm_Aggregator.{remove,change}Element() assumes none of these is equal to -1!
- const ACM_SOURCE_HISTORY = 0;
- const ACM_SOURCE_BOOKMARKS = 1;
-
- // holds the bookmarks folders for use in the aggregator
- var acm_bookmarkFolders = [];
-
- // object for history and bookmark entries
- function AutocompleteCandidate(id, title, URL, strippedURL, strippedTitle, webpath, domain,
- firstvisit, lastvisit, icon, visitcount, resource, source) {
- // unique id of this entry: order by which it was inserted in the history array;
- // -1 for bookmarks or history entries entered by observers
- this.id = id;
-
- // if you change the names of the following, also change the 'onclick' handlers of the history treecols
- this.title = title;
- this.URL = URL;
-
- this.strippedURL = strippedURL;
- this.strippedTitle = strippedTitle;
- this.webpath = webpath;
- this.domain = domain;
-
- this.first_visit = firstvisit;
- this.last_visit = lastvisit;
- this.icon = icon; // URL of the favicon, "" if none
- this.visit_count = visitcount;
- this.resource = resource; // the nsIRDFResource of this entry; used to detect duplicate bookmarks
- this.source = source; // history or bookmark datasource
-
- // what this entry matched against
- //this.matched_against = "";
- }
-
- // searches for a bookmark with the given URL
- function acm_findBookmark(URL)
- {
- var resURL = acm_rdfService.GetLiteral(URL);
- var resFoundBookmark = acm_dsBookmarks.GetSource(acm_resURL, resURL, true);
-
- if (resFoundBookmark) {
- var nodeName = acm_dsBookmarks.GetTarget(resFoundBookmark, acm_resName, true);
- if (nodeName === null)
- nodeName = acm_rdfService.GetLiteral("");
- nodeName.QueryInterface(Components.interfaces.nsIRDFLiteral);
-
- alert("Found " + URL + " with title " + nodeName.Value);
- }
- else
- alert(URL + " was not found in the bookmarks file!");
- }
-
- // searches for a history entry with the given URL
- function acm_findHistEntry(URL)
- {
- var resURL = acm_rdfService.GetResource(URL);
- // the source for a history entry is its URL
- var found = acm_dsHistory.GetTarget(resURL, acm_resURL, true);
-
- if (found) {
- var nodeTitle = acm_dsHistory.GetTarget(resURL, acm_resName, true);
- if (nodeTitle === null)
- nodeTitle = acm_rdfService.GetLiteral("");
- nodeTitle.QueryInterface(Components.interfaces.nsIRDFLiteral);
-
- alert("Found " + URL + " with title " + nodeTitle.Value);
- }
- else
- alert(URL + " was not found in the history file!");
- }
-
- // returns an array with all bookmarks as AutocompleteCandidate objects
- function acm_getBookmarks()
- {
- // alternative method of getting the bookmarks
- //var elements = acm_dsBookmarks.GetAllResources();
- //while(elements.hasMoreElements()) {
- // var item = elements.getNext();
- // if(acm_dsBookmarks.hasArcOut(item, acm_resURL)) {
- // var nodeURL = acm_dsBookmarks.GetTarget(item, acm_resURL, true);
- // if (nodeURL === null)
- // nodeURL = acm_rdfService.GetLiteral("");
- // nodeURL.QueryInterface(Components.interfaces.nsIRDFLiteral);
- // }
- //}
-
- // start with the root folder, and add subfolders to iterate over
- var resBookmarksRoot = acm_rdfService.GetResource("NC:BookmarksRoot");
- var folders = [resBookmarksRoot];
- // container service; not available at startup!
- var container = Components.classes["@mozilla.org/rdf/container;1"]
- .getService(Components.interfaces.nsIRDFContainer);
-
- while (folders.length > 0) {
- // TOFIX: shifting is expensive!
- container.Init(acm_dsBookmarks, folders.shift());
- var elements = container.GetElements(); // all items in this folder
- while (elements.hasMoreElements()) {
- var item = elements.getNext();
- item.QueryInterface(Components.interfaces.nsIRDFResource);
- var resItem = acm_rdfService.GetResource(item.Value);
-
- // get this item's type
- var nodeType = acm_dsBookmarks.GetTarget(resItem, acm_resBookmarkType, true);
- nodeType.QueryInterface(Components.interfaces.nsIRDFResource);
-
- // bookmark folder; add it to the list of folders
- if (nodeType.Value === "http://home.netscape.com/NC-rdf#Folder") {
- folders.push(item);
- acm_bookmarkFolders.push(resItem);
- }
-
- // regular bookmark
- else if (nodeType.Value === "http://home.netscape.com/NC-rdf#Bookmark") {
- var nodeName = acm_dsBookmarks.GetTarget(resItem, acm_resName, true);
- if (nodeName === null)
- nodeName = acm_rdfService.GetLiteral("");
- nodeName.QueryInterface(Components.interfaces.nsIRDFLiteral);
-
- // strip off common protocols and prefixes, and only keep letters and digits
- var strippedTitle = nodeName.Value.toLowerCase();
- strippedTitle = strippedTitle.replace(acm_nonLetterDigitSpace, "");
-
- var nodeURL = acm_dsBookmarks.GetTarget(resItem, acm_resURL, true);
- if (nodeURL === null)
- nodeURL = acm_rdfService.GetLiteral("");
- nodeURL.QueryInterface(Components.interfaces.nsIRDFLiteral);
-
- // decode URL
- var url = nodeURL.Value;
- try {
- url = decodeURI(url);
- }
- catch (e) {
- // if URL is malformed, keep it as is
- }
-
- // strip off common protocols and prefixes, and only keep letters and digits
- var strippedURL = url.toLowerCase().replace(acm_commonProtocol, "");
- strippedURL = strippedURL.replace(acm_commonPrefix, "");
- strippedURL = strippedURL.replace(acm_nonLetterDigitSpace, "");
-
- // to determine whether the URL represents a top-level domain address,
- // check the position of the first slash after the longest possible protocol (https://)
- var domain = false;
- var pos = url.indexOf("/", 8);
- if (pos === -1 || pos === url.length - 1)
- domain = true;
-
- // a URL is a Web path if it ends in a slash, if it is a top-level domain, or
- // if there is no '.' after the last slash
- var webpath = false;
- var lastSlash = url.lastIndexOf("/");
- if (lastSlash === url.length - 1 || domain || url.indexOf(".", lastSlash + 1) === -1)
- webpath = true;
-
- var nodeFirstVisit = acm_dsBookmarks.GetTarget(resItem, acm_resBookFirstVisit, true);
- if (nodeFirstVisit === null)
- nodeFirstVisit = acm_rdfService.GetDateLiteral(0);
- nodeFirstVisit.QueryInterface(Components.interfaces.nsIRDFDate);
-
- var nodeLastVisit = acm_dsBookmarks.GetTarget(resItem, acm_resBookLastVisit, true);
- if (nodeLastVisit === null)
- nodeLastVisit = acm_rdfService.GetDateLiteral(0);
- nodeLastVisit.QueryInterface(Components.interfaces.nsIRDFDate);
-
- var nodeIcon = acm_dsBookmarks.GetTarget(resItem, acm_resBookIcon, true);
- if (nodeIcon === null)
- nodeIcon = acm_rdfService.GetLiteral("");
- nodeIcon.QueryInterface(Components.interfaces.nsIRDFLiteral);
-
- // find bookmark's visit count from history
- var visit_count = 0;
- var resURL = acm_rdfService.GetResource(nodeURL.Value);
- var found = acm_dsHistory.GetTarget(resURL, acm_resURL, true);
-
- if (found) {
- var nodeVisitCount = acm_dsHistory.GetTarget(resURL, acm_resVisitCount, true);
- if (nodeVisitCount === null)
- nodeVisitCount = acm_rdfService.GetIntLiteral(0);
- nodeVisitCount.QueryInterface(Components.interfaces.nsIRDFInt);
- visit_count = nodeVisitCount.Value;
- }
-
- var candidate = new AutocompleteCandidate(-1, nodeName.Value, url, strippedURL, strippedTitle,
- webpath, domain, nodeFirstVisit.Value, nodeLastVisit.Value,
- nodeIcon.Value, visit_count, resItem, ACM_SOURCE_BOOKMARKS);
-
- yield candidate;
- }
-
- else if (nodeType.Value === "http://home.netscape.com/NC-rdf#Livemark")
- ; // do not add livemarks
- }
- }
-
- yield null; // return null when done
- }
-
- // generator: returns history entries one by one as AutocompleteCandidate objects
- function acm_getHistoryItems()
- {
- var resHistoryRoot = acm_rdfService.GetResource("NC:HistoryRoot");
- // get the children of the history root, i.e. all the history items
- var elements = acm_dsHistory.GetTargets(resHistoryRoot, acm_resChild, true);
- var entryIndex = 0;
- while(elements.hasMoreElements()) {
- var item = elements.getNext();
- item.QueryInterface(Components.interfaces.nsIRDFResource);
- // item.Value contains the URL, which is the source for this history entry
- var resItem = acm_rdfService.GetResource(item.Value);
-
- var nodeTitle = acm_dsHistory.GetTarget(resItem, acm_resName, true);
- if (nodeTitle === null)
- nodeTitle = acm_rdfService.GetLiteral("");
- nodeTitle.QueryInterface(Components.interfaces.nsIRDFLiteral);
-
- // strip off common protocols and prefixes, and only keep letters and digits
- var strippedTitle = nodeTitle.Value.toLowerCase();
- strippedTitle = strippedTitle.replace(acm_nonLetterDigitSpace, "");
-
- var nodeURL = acm_dsHistory.GetTarget(resItem, acm_resURL, true);
- if (nodeURL === null)
- nodeURL = acm_rdfService.GetLiteral("");
- nodeURL.QueryInterface(Components.interfaces.nsIRDFLiteral);
-
- // decode URL
- var url = nodeURL.Value;
- try {
- url = decodeURI(url);
- }
- catch (e) {
- // if URL is malformed, keep it as is
- }
-
- // strip off common protocols and prefixes and only keep letters and digits
- var strippedURL = url.toLowerCase().replace(acm_commonProtocol, "");
- strippedURL = strippedURL.replace(acm_commonPrefix, "");
- strippedURL = strippedURL.replace(acm_nonLetterDigitSpace, "");
-
- // to determine whether the URL represents a top domain address,
- // check the position of the first slash after the longest possible protocol (https://)
- var domain = false;
- var pos = url.indexOf("/", 8);
- if (pos === -1 || pos === url.length - 1)
- domain = true;
-
- // a URL is a Web path if it ends in a slash, if it is a top-level domain, or
- // if there is no '.' after the last slash
- var webpath = false;
- var lastSlash = url.lastIndexOf("/");
- if (lastSlash === url.length - 1 || domain || url.indexOf(".", lastSlash + 1) === -1)
- webpath = true;
-
- var nodeFirstVisit = acm_dsHistory.GetTarget(resItem, acm_resHistFirstVisit, true);
- if (nodeFirstVisit === null)
- nodeFirstVisit = acm_rdfService.GetDateLiteral(0);
- nodeFirstVisit.QueryInterface(Components.interfaces.nsIRDFDate);
-
- var nodeLastVisit = acm_dsHistory.GetTarget(resItem, acm_resHistLastVisit, true);
- if (nodeLastVisit === null)
- nodeLastVisit = acm_rdfService.GetDateLiteral(0);
- nodeLastVisit.QueryInterface(Components.interfaces.nsIRDFDate);
-
- // find favicon from bookmarks
- var favicon = "";
- var resURL = acm_rdfService.GetLiteral(nodeURL.Value);
- var resBookmark = acm_dsBookmarks.GetSource(acm_resURL, resURL, true);
-
- if (resBookmark) {
- var nodeIcon = acm_dsBookmarks.GetTarget(resBookmark, acm_resBookIcon, true);
- if (nodeIcon === null)
- nodeIcon = acm_rdfService.GetLiteral("");
- nodeIcon.QueryInterface(Components.interfaces.nsIRDFLiteral);
- favicon = nodeIcon.Value;
- }
-
- var nodeVisitCount = acm_dsHistory.GetTarget(resItem, acm_resVisitCount, true);
- if (nodeVisitCount === null)
- nodeVisitCount = acm_rdfService.GetIntLiteral(0);
- nodeVisitCount.QueryInterface(Components.interfaces.nsIRDFInt);
-
- var candidate = new AutocompleteCandidate(entryIndex++, nodeTitle.Value, url,
- strippedURL, strippedTitle, webpath, domain, nodeFirstVisit.Value,
- nodeLastVisit.Value, favicon, nodeVisitCount.Value, resItem, ACM_SOURCE_HISTORY);
-
- yield candidate;
- }
-
- yield null; // return null when done
- }
-
- // returns the info for a bookmark or history entry as an AutocompleteCandidate object
- function acm_getEntryInfo(datasource, resItem)
- {
- if (datasource.URI === acm_dsHistory.URI) {
- var nodeTitle = acm_dsHistory.GetTarget(resItem, acm_resName, true);
- if (nodeTitle === null)
- nodeTitle = acm_rdfService.GetLiteral("");
- nodeTitle.QueryInterface(Components.interfaces.nsIRDFLiteral);
-
- // strip off common protocols and prefixes, and only keep letters and digits
- var strippedTitle = nodeTitle.Value.toLowerCase();
- strippedTitle = strippedTitle.replace(acm_nonLetterDigitSpace, "");
-
- var nodeURL = acm_dsHistory.GetTarget(resItem, acm_resURL, true);
- if (nodeURL === null)
- nodeURL = acm_rdfService.GetLiteral("");
- nodeURL.QueryInterface(Components.interfaces.nsIRDFLiteral);
-
- // decode URL
- var url = nodeURL.Value;
- try {
- url = decodeURI(url);
- }
- catch (e) {
- // if URL is malformed, keep it as is
- }
-
- // strip off common protocols and prefixes and only keep letters and digits
- var strippedURL = url.toLowerCase().replace(acm_commonProtocol, "");
- strippedURL = strippedURL.replace(acm_commonPrefix, "");
- strippedURL = strippedURL.replace(acm_nonLetterDigitSpace, "");
-
- // to determine whether the URL represents a top domain address,
- // check the position of the first slash after the longest possible protocol (https://)
- var domain = false;
- var pos = url.indexOf("/", 8);
- if (pos === -1 || pos === url.length - 1)
- domain = true;
-
- // a URL is a Web path if it ends in a slash, if it is a top-level domain, or
- // if there is no '.' after the last slash
- var webpath = false;
- var lastSlash = url.lastIndexOf("/");
- if (lastSlash === url.length - 1 || domain || url.indexOf(".", lastSlash + 1) === -1)
- webpath = true;
-
- var nodeFirstVisit = acm_dsHistory.GetTarget(resItem, acm_resHistFirstVisit, true);
- if (nodeFirstVisit === null)
- nodeFirstVisit = acm_rdfService.GetDateLiteral(0);
- nodeFirstVisit.QueryInterface(Components.interfaces.nsIRDFDate);
-
- var nodeLastVisit = acm_dsHistory.GetTarget(resItem, acm_resHistLastVisit, true);
- if (nodeLastVisit === null)
- nodeLastVisit = acm_rdfService.GetDateLiteral(0);
- nodeLastVisit.QueryInterface(Components.interfaces.nsIRDFDate);
-
- // find favicon from bookmarks
- var favicon = "";
- var resURL = acm_rdfService.GetLiteral(nodeURL.Value);
- var resBookmark = acm_dsBookmarks.GetSource(acm_resURL, resURL, true);
-
- if (resBookmark) {
- var nodeIcon = acm_dsBookmarks.GetTarget(resBookmark, acm_resBookIcon, true);
- if (nodeIcon === null)
- nodeIcon = acm_rdfService.GetLiteral("");
- nodeIcon.QueryInterface(Components.interfaces.nsIRDFLiteral);
- favicon = nodeIcon.Value;
- }
-
- var nodeVisitCount = acm_dsHistory.GetTarget(resItem, acm_resVisitCount, true);
- if (nodeVisitCount === null)
- nodeVisitCount = acm_rdfService.GetIntLiteral(0);
- nodeVisitCount.QueryInterface(Components.interfaces.nsIRDFInt);
-
- return new AutocompleteCandidate(-1, nodeTitle.Value, url, strippedURL, strippedTitle,
- webpath, domain, nodeFirstVisit.Value, nodeLastVisit.Value,
- favicon, nodeVisitCount.Value, resItem, ACM_SOURCE_HISTORY);
- }
- else if (datasource.URI === acm_dsBookmarks.URI) {
- // resItem may represent the URL or the resource of the bookmark
- var resURL = acm_rdfService.GetLiteral(resItem);
- var resBookmark = acm_dsBookmarks.GetSource(acm_resURL, resURL, true);
- if (!resBookmark)
- resBookmark = resItem;
-
- // get this bookmark's type
- var nodeType = acm_dsBookmarks.GetTarget(resBookmark, acm_resBookmarkType, true);
- if (!nodeType) // maybe it's too early to get the details of this bookmark
- return null;
- nodeType.QueryInterface(Components.interfaces.nsIRDFResource);
-
- // only add regular bookmarks
- if (nodeType.Value !== "http://home.netscape.com/NC-rdf#Bookmark")
- return null;
-
- var nodeName = acm_dsBookmarks.GetTarget(resBookmark, acm_resName, true);
- if (nodeName === null)
- nodeName = acm_rdfService.GetLiteral("");
- nodeName.QueryInterface(Components.interfaces.nsIRDFLiteral);
-
- // strip off common protocols and prefixes, and only keep letters and digits
- var strippedTitle = nodeName.Value.toLowerCase();
- strippedTitle = strippedTitle.replace(acm_nonLetterDigitSpace, "");
-
- var nodeURL = acm_dsBookmarks.GetTarget(resBookmark, acm_resURL, true);
- if (nodeURL === null)
- nodeURL = acm_rdfService.GetLiteral("");
- nodeURL.QueryInterface(Components.interfaces.nsIRDFLiteral);
-
- // decode URL
- var url = nodeURL.Value;
- try {
- url = decodeURI(url);
- }
- catch (e) {
- // if URL is malformed, keep it as is
- }
-
- // strip off common protocols and prefixes and only keep letters and digits
- var strippedURL = url.toLowerCase().replace(acm_commonProtocol, "");
- strippedURL = strippedURL.replace(acm_commonPrefix, "");
- strippedURL = strippedURL.replace(acm_nonLetterDigitSpace, "");
-
- // to determine whether the URL represents a top domain address,
- // check the position of the first slash after the longest possible protocol (https://)
- var domain = false;
- var pos = url.indexOf("/", 8);
- if (pos === -1 || pos === url.length - 1)
- domain = true;
-
- // a URL is a Web path if it ends in a slash, if it is a top-level domain, or
- // if there is no '.' after the last slash
- var webpath = false;
- var lastSlash = url.lastIndexOf("/");
- if (lastSlash === url.length - 1 || domain || url.indexOf(".", lastSlash + 1) === -1)
- webpath = true;
-
- var nodeFirstVisit = acm_dsBookmarks.GetTarget(resBookmark, acm_resBookFirstVisit, true);
- if (nodeFirstVisit === null)
- nodeFirstVisit = acm_rdfService.GetDateLiteral(0);
- nodeFirstVisit.QueryInterface(Components.interfaces.nsIRDFDate);
-
- var nodeLastVisit = acm_dsBookmarks.GetTarget(resBookmark, acm_resBookLastVisit, true);
- if (nodeLastVisit === null)
- nodeLastVisit = acm_rdfService.GetDateLiteral(0);
- nodeLastVisit.QueryInterface(Components.interfaces.nsIRDFDate);
-
- var nodeIcon = acm_dsBookmarks.GetTarget(resItem, acm_resBookIcon, true);
- if (nodeIcon === null)
- nodeIcon = acm_rdfService.GetLiteral("");
- nodeIcon.QueryInterface(Components.interfaces.nsIRDFLiteral);
-
- // find bookmark's visit count from history
- var visit_count = 0;
- var resURL = acm_rdfService.GetResource(nodeURL.Value);
- var found = acm_dsHistory.GetTarget(resURL, acm_resURL, true);
-
- if (found) {
- var nodeVisitCount = acm_dsHistory.GetTarget(resURL, acm_resVisitCount, true);
- if (nodeVisitCount === null)
- nodeVisitCount = acm_rdfService.GetIntLiteral(0);
- nodeVisitCount.QueryInterface(Components.interfaces.nsIRDFInt);
- visit_count = nodeVisitCount.Value;
- }
-
- return new AutocompleteCandidate(-1, nodeName.Value, url, strippedURL, strippedTitle,
- webpath, domain, nodeFirstVisit.Value, nodeLastVisit.Value,
- nodeIcon.Value, visit_count, resBookmark, ACM_SOURCE_BOOKMARKS);
- }
-
- return null;
- }
-
- // Adds new history entries to the history file;
- // the observers take care of adding these to the candidate list.
- // NOTE: this only saves the title and URL right now! When Asserts for history are
- // implemented, we will be able to add the other properties as well.
- function acm_addNewHistEntries()
- {
- acm_dsHistory.beginUpdateBatch();
- var globalHistory = Components.classes["@mozilla.org/browser/global-history;2"]
- .getService(Components.interfaces.nsIGlobalHistory2);
-
- for (var i = 0, len = acm_addedHistEntries.length; i < len; i++) {
- var newEntry = acm_addedHistEntries[i];
- var newURI = acm_ioService.newURI(newEntry.URL, null, null);
- globalHistory.addURI(newURI, false, true, null);
- globalHistory.setPageTitle(newURI, newEntry.title);
-
- var resURL = acm_rdfService.GetResource(newEntry.URL);
-
- // cannot even access the nodes of this entry, let alone change them!
- //var nodeVisitCount = acm_dsHistory.GetTarget(resURL, acm_resVisitCount, true);
- //nodeVisitCount.QueryInterface(Components.interfaces.nsIRDFInt);
- //alert(nodeVisitCount.Value);
- //acm_dsHistory.Change(resURL, acm_resVisitCount, nodeVisitCount,
- // acm_rdfService.GetIntLiteral(newEntry.visit_count));
-
- // when asserts are implemented for history, this should work!
- //acm_dsHistory.Assert(resURL, acm_resHistFirstVisit,
- // acm_rdfService.GetDateLiteral(newEntry.first_visit), true);
- //acm_dsHistory.Assert(resURL, acm_resHistLastVisit,
- // acm_rdfService.GetDateLiteral(newEntry.last_visit), true);
- //acm_dsHistory.Assert(resURL, acm_resVisitCount,
- // acm_rdfService.GetIntLiteral(newEntry.visit_count), true);
- }
- acm_dsHistory.endUpdateBatch();
- acm_addedHistEntries = [];
- }
-
- // updates edited history entries in the history file
- function acm_updateEditedHistEntries()
- {
- // remove the old version of edited entries from the aggregator list
- for (var j = 0, len = acm_editedURLs.length; j < len; j++) {
- for (var i = acm_Aggregator.allCandidates.length - 1; i >= 0; i--) {
- if ( (acm_Aggregator.allCandidates[i].source === ACM_SOURCE_HISTORY)
- && (acm_Aggregator.allCandidates[i].URL === acm_editedURLs[j]) ) {
- acm_Aggregator.allCandidates.splice(i, 1);
- break;
- }
- }
- }
-
- // add new version of edited entries to the aggregator list
- // NOTE: an entry may be added twice due to an Assert, but not always!
- // This will be fixed if we figure out how to insert entries using assertions!
- Array.prototype.push.apply(acm_Aggregator.allCandidates, acm_editedHistEntries);
-
- acm_editedHistEntries = [];
- acm_editedURLs = [];
- }
-
- // removes deleted history entries from the history file;
- // the observers take care of removing those from the candidate list
- function acm_removeDeletedHistEntries() {
- for (var i = 0, len = acm_deletedHistEntries.length; i < len; i++) {
- var deletedEntry = acm_deletedHistEntries[i];
- var uriToDelete = acm_ioService.newURI(deletedEntry.URL, null, null);
- acm_browserHistory.removePage(uriToDelete);
- }
-
- acm_deletedHistEntries = [];
- }
-